import 'dart:convert' show json;

import 'package:x3_base_package/x3_base_package.dart';
import 'package:x3_business_core/common_models/base_business_model.dart';

class UserModel extends BaseBusinessModel {
  UserModel({
    this.img,
    this.userName,
    this.userId,
    bool check,
  }) : super(userId, userName, check: check);

  factory UserModel.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : UserModel(
          img: asT<String>(jsonRes['img']),
          userName: asT<String>(jsonRes['userName']),
          userId: asT<String>(jsonRes['userId']),
          check: asT<bool>(jsonRes['check']),
        );

  String img;
  String userName;
  String userId;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'headImg': img,
        'name': userName,
        'userId': userId,
      };
  @override
  String toString() {
    return json.encode(this);
  }
}
